{extend name="public/base" /}
{block name="pjax_container"}
<?php
    $titleTypeName = ' 全局参数设置';
?>
<style>

h3{
    font-size: 14px;
     color: #67A5DF;
}
input{
    text-align: center;
    border-radius: 5px !important;
    margin-bottom: 10px;
}
html{
    color: #333;
}
 
.content-header>.breadcrumb>li{
    color: #999;
}
.content-header>.breadcrumb>.active{
    color: #666;
}
.content-header{
    height: 51px;
 
}
.btn-primary{
    background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 5px 10px; 
}
.box-primary{
  border-top-color: #ecf0f5 !important;
  border-top-width: 16px;
  
}
.btn-primary:hover{
     background-color: #1890FF;
    color: #fff;
    border: none;
    opacity: .9;
    border-radius: 6px !important; 
}
.delete-one{
    background-color: ff4141 !important;
    margin-left: 15px;
    border-radius: 6px;
}
.tab-content {
    margin: 20px 0 40px;
    border-bottom: 0px solid #f3f3f3;
    padding-bottom: 40px;
}
.form-group{                                            
    	position: relative;                                                                                                 
}
.glyphicon-plus,.glyphicon-minus{
    position: absolute;
    left: 370px;
    top: 40%;
    font-size: 20px;
    color: #0081ff;
    text-align: center;
    transform: translateY(-50%);
}
</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>系统管理</li>
        <li class="active">{$titleTypeName}</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <form class="form-horizontal" method="POST" action="/{$Think.MODULE_NAME}/{$Think.CONTROLLER_NAME}/overall_edit" onsubmit="return false" >
                <div class="nav-tabs-custom">
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab1">
                            <h3>日常奖扣</h3>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">奖扣人次：</label>
                                <div class="col-sm-10" id="record_people_num" style="display: flex;">
                                   <span style="padding-top: 5px;margin-right: 5px;">人次：</span><input class="form-control" style="width:80px;" type="number" name="people_sum[]" value="{$info['people_sum']|default=''}" placeholder="人次">
                                    <span style="margin: 5px 5px 5px 10px;">奖分：</span>    <input class="form-control" style="width:80px;"  type="number" name="prize_integral[]" value="{$info['prize_integral']|default=''}" placeholder="奖分">
                                    <p class="glyphicon glyphicon-plus"></p>
                                </div>
                            </div>
                            <div class="group_div">
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">奖扣事件数：</label>
                                <div class="col-sm-3" id="record_event_num" style="display: flex;">
                                  <span style="padding-top: 5px;margin-right: 5px;">事件数：</span> <input class="form-control" style="width:80px;"  type="number" name="prize_sum[]" value="{$info['prize_sum']|default=''}" placeholder="事件数">
                                   <span style="margin: 5px 5px 5px 10px;">奖分：</span> <input class="form-control" style="width:80px;" type="number" name="event_prize_integral[]" value="{$info['event_prize_integral']|default=''}" placeholder="奖分">
                                     <p class="glyphicon glyphicon-plus" style=" left: 370px;"></p>
                                </div>
                            </div>
                                <div class="group_div2">
                                </div>
                            <h3 style="margin-top: 80px;">任务大厅（记录人奖分）</h3>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">奖分：</label>
                                <div class="col-sm-2">
                                    <input class="form-control" style="width:80px;"  type="number" name="record" value="{$info['record']|default=''}" placeholder="">
                                </div>
                            </div>

                            <h3 style="margin-top: 80px;">请假设置</h3>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">事假每天扣分：</label>
                                <div class="col-sm-2">
                                    <input class="form-control"  type="number" name="leave_thing" value="{$info['leave_thing']|default=''}" placeholder="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">病假每天扣分：</label>
                                <div class="col-sm-2">
                                    <input class="form-control" type="number" name="leave_sick" value="{$info['leave_sick']|default=''}" placeholder="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">其他每天扣分：</label>
                                <div class="col-sm-2">
                                    <input class="form-control" type="number" name="leave_other" value="{$info['leave_other']|default=''}" placeholder="">
                                </div>
                            </div>

                            <h3 style="margin-top: 80px;">其它配置：</h3>
<!--                            <div class="form-group">-->
<!--                                <label class="col-sm-2 control-label">AB分转换倍数：</label>-->
<!--                                <div class="col-sm-2">-->
<!--                                    <input class="form-control" type="number" name="change" value="{$info['change']|default=''}" placeholder="">-->
<!--                                </div>-->
<!--                            </div>-->
                           
                            <div class="form-group">
                                <label class="col-sm-2 control-label">全勤奖分：</label>
                                <div class="col-sm-2">
                                    <input class="form-control" type="number" name="all_integral" value="{$info['all_integral']|default=''}" placeholder="">
                                </div>
                            </div>
                            {include file="form/switch1" title="是否开启前端商城" name="is_open_shop" data="isset($info['is_open_shop']) ? $info['is_open_shop'] : 1"/}
                            {include file="form/switch1" title="是否开启前端自定义排名" name="is_open_ranking" data="isset($info['is_open_ranking']) ? $info['is_open_ranking'] : 1"/}

                        </div>
                    </div>

                    <div class="box-footer">
                        <div class="col-sm-2"></div>
                        <div class="col-sm-2">
                            <div class="btn-group pull-right">
                                <button style="width: 100px;height:40px; " type="submit" class="btn btn-info pull-right submits" data-loading-text="&lt;i class='fa fa-spinner fa-spin '&gt;&lt;/i&gt; 提交">提交</button>
                            </div>
                        </div>
                    </div>

                </div>
            </form>
        </div>
    </div>
</section>
<script type="application/javascript">
    $(document).ready(function () {
        /*ajax页面加载icheck，有该控件的页面才需要*/
        $(".select2").select2({language: "zh-CN"});

        $('.timepicker').datetimepicker({
            format: "{$timepickerFormat | default='HH:mm'}",   //YYYY-MM-DD HH:mm:ss
            locale: moment.locale('zh-cn')
        });
    })
    let glyphiconPlus = document.querySelectorAll(".glyphicon-plus");
    let tabPane = document.querySelector(".group_div");
    let tabPane2 = document.querySelector(".group_div2");
         let    maxnum = 1;

    glyphiconPlus[0].onclick = function () {
       if (maxnum === 5) {
            alert("不能再创建了");
            return;
        }
        add_glyphicon_plus();
     

        
    };

    //赋值默认的奖扣人次
    {foreach name="$info['record_people_num']" item="vo" key="ko"}
        {if condition="$ko == 0"}
            $('#record_people_num').find('input:eq(0)').val({$vo.people_sum});
            $('#record_people_num').find('input:eq(1)').val({$vo.prize_integral});
        {else/}
            add_glyphicon_plus({$vo.people_sum}, {$vo.prize_integral});
        {/if}
    {/foreach}
    //奖扣人次添加元素
    function add_glyphicon_plus(people_sum = 0, prize_integral = 0) {
        let div = document.createElement("div");
        let label = document.createElement("label");
        let div2 = document.createElement("div");
        let span = document.createElement("span");
        let span2 = document.createElement("span");
        let input = document.createElement("input");
        let input2 = document.createElement("input");
        let p = document.createElement("p");
        div.className = "form-group";
        label.className = "col-sm-2 control-label";
        label.innerText = "奖扣人次：";
        div2.className = "col-sm-6";
        div2.setAttribute("style", "display: flex;");
        span.setAttribute("style", "padding-top: 5px;margin-right: 5px;");
        span.innerText = "人次：  ";
        input.className = "form-control";
        input.setAttribute("style", "width:80px;");
        input.setAttribute("type", "number");
        input.setAttribute("name", "people_sum[]");
        input.setAttribute("value", people_sum);
        input.setAttribute("placeholder", "人次");
        span2.setAttribute("style", "margin: 5px 5px 5px 10px;");
        span2.innerText = "奖分：";
        input2.className = "form-control";
        input2.setAttribute("style", "width:80px;");
        input2.setAttribute("type", "number");
        input2.setAttribute("name", "prize_integral[]");
        input2.setAttribute("value", prize_integral);
        input2.setAttribute("placeholder", "奖分");
        p.className = "glyphicon glyphicon-minus";
        div.appendChild(label);
        div.appendChild(div2);
        div2.appendChild(span);
        div2.appendChild(input);
        div2.appendChild(span2);
        div2.appendChild(input2);
        div2.appendChild(p);
        tabPane.appendChild(div);
           maxnum += 1;
        let glyphiconMinus = document.querySelectorAll(".glyphicon-minus");
        for (let i = 0; i < glyphiconMinus.length; i++) {
            glyphiconMinus[i].onclick = function () {
                this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
                     maxnum -= 1;
            }
        }
    }


                let maxplus = 1;
    glyphiconPlus[1].onclick = function () {
           if (maxplus === 5) {
            alert("不能再创建了");
            return;
        }
        console.log(maxplus);
        add_glyphicon_plus2();
        
    }
    //赋值默认的奖扣事件数
    {foreach name="$info['record_event_num']" item="vo" key="ko"}
        {if condition="$ko == 0"}
            $('#record_event_num').find('input:eq(0)').val({$vo.prize_sum});
            $('#record_event_num').find('input:eq(1)').val({$vo.event_prize_integral});
        {else/}
            add_glyphicon_plus2({$vo.prize_sum}, {$vo.event_prize_integral});
        {/if}
    {/foreach}
    //奖扣事件数添加元素
    function add_glyphicon_plus2(prize_sum=0, event_prize_integral=0) {
        let div = document.createElement("div");
        let label = document.createElement("label");
        let div2 = document.createElement("div");
        let span = document.createElement("span");
        let span2 = document.createElement("span");
        let input = document.createElement("input");
        let input2 = document.createElement("input");
        let p = document.createElement("p");
        div.className = "form-group";
        label.className = "col-sm-2 control-label";
        label.innerText = "奖扣事件数：";
        div2.className = "col-sm-6";
        div2.setAttribute("style", "display: flex;");
        span.setAttribute("style", "padding-top: 5px;margin-right: 5px;");
        span.innerText = "事件数：";
        input.className = "form-control";
        input.setAttribute("style", "width:80px;");
        input.setAttribute("type", "number");
        input.setAttribute("name", "prize_sum[]");
        input.setAttribute("value", prize_sum);
        input.setAttribute("placeholder", "事件数");
        span2.setAttribute("style", "margin: 5px 5px 5px 10px;");
        span2.innerText = "奖分：";
        input2.className = "form-control";
        input2.setAttribute("style", "width:80px;");
        input2.setAttribute("type", "number");
        input2.setAttribute("name", "event_prize_integral[]");
        input2.setAttribute("value", event_prize_integral);
        input2.setAttribute("placeholder", "奖分");
        p.className = "glyphicon glyphicon-minus";
        div.appendChild(label);
        div.appendChild(div2);
        div2.appendChild(span);
        div2.appendChild(input);
        div2.appendChild(span2);
        div2.appendChild(input2);
        div2.appendChild(p);
        tabPane2.appendChild(div);
        maxplus +=1;
        let glyphiconMinus = document.querySelectorAll(".glyphicon-minus");
        for (let i = 0; i < glyphiconMinus.length; i++) {
            glyphiconMinus[i].onclick = function () {
                this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
                maxplus -=1;
            }
        }
    }

</script>
{/block}
